<script setup lang="ts">
import { getWarningDetailAPI } from '@/apis/pole';
import type { WarningDetailData } from '@/types/pole';
import { onMounted, ref } from 'vue';
import { useRoute } from 'vue-router';


const detail = ref<WarningDetailData>()
const route = useRoute()
const getDetail = async () => {
  const res = await getWarningDetailAPI(Number(route.params.id))
  console.log('detail',res)
  detail.value = res.data
}
onMounted(() => {
  getDetail()
})
</script>

<template>
  <div class="add-enterprise">
    <header class="add-header">
      <el-page-header content="告警详情" @back="$router.back()" />
    </header>
    <main class="add-main">
      <div class="form-container">
        <div class="title">告警详情</div>
        <div class="box">
          <div class="mbox">
          <div class="item">告警时间：{{ detail?.warningTime}}</div>
          <div class="item">告警区域：{{ detail?.areaName }}</div>
          <div class="item">故障类型：{{ detail?.errorType }}</div>
        </div>
        <div class="mbox">
          <div class="item">一体杆名称：{{ detail?.poleName }}</div>
          <div class="item">一体杆编号：{{ detail?.poleNumber }}</div>
          <div class="item">处置状态：
            <span v-if="detail?.handleStatus === 0">未派单</span>
            <span v-else-if="detail?.handleStatus === 1">已派单</span>
            <span v-else-if="detail?.handleStatus === 2">已接单</span>
            <span v-else-if="detail?.handleStatus === 3">已完成</span>
          </div>
        </div>
        </div>
      </div>
      <div class="form-container">
        <div class="title">告警处理</div>
        <div class="box">
        <div class="mbox">
          <div class="item">处理人：{{ detail?.handleUser }}</div>
          <div class="item">处理结果：{{ detail?.handleResult }}</div>
        </div>
        <div class="mbox">
          <div class="item">联系方式：{{ detail?.phonenumber }}</div>
          <div class="item">完成时间：{{ detail?.handleTime }}</div>
        </div>
        </div>
      </div>
    </main>
  </div>
</template>

<style scoped lang="scss">
.add-enterprise {
  background-color: #f4f6f8;
  height: 100vh;

  .add-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    height: 64px;
    line-height: 64px;
    font-size: 16px;
    font-weight: bold;
    background-color: #fff;

    .left {
      span {
        margin-right: 4px;
      }

      .arrow {
        cursor: pointer;
      }
    }

    .right {
      text-align: right;
    }
  }

  .add-main {
    background: #f4f6f8;
    padding: 20px 130px;

    .form-container {
      background-color: #fff;
      margin-top: 20px;
      .title {
        height: 60px;
        line-height: 60px;
        padding-left: 20px;
      }
      .box {
        display: flex;
        justify-content: space-around;
        padding: 30px;
        .mbox {
          display: flex;
          flex-direction: column;
          gap: 10px;
        }
      }
      
    }
  }

}
</style>